<template>
  <div class="platform">
    <!-- 搜索 -->
    <div class="platform-search">
      <div class="search-btn">
        <el-button type="primary" plain>添加终端信息</el-button>
      </div>
      <div class="search-form">
        <el-input v-model="search" placeholder="请输入搜索内容..."></el-input>
      </div>
    </div>
    <!-- 列表 -->
    <div class="platform-table">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column fixed prop="name" label="服务器名称" width="100">
        </el-table-column>
        <el-table-column prop="address" label="服务器地址" width="160"> </el-table-column>
        <el-table-column prop="user" label="登录用户名" width="100"> </el-table-column>
        <el-table-column prop="pass" label="登录密码"> </el-table-column>
        <el-table-column prop="port" label="端口号" width="80"> </el-table-column>
        <el-table-column prop="note" label="备注" width="100"> </el-table-column>
        <el-table-column fixed="right" label="操作" width="190">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small"
              class="start-btn" >运行</el-button
            >
            <el-button type="text" size="small" class="upt-btn">编辑</el-button>
            <el-button type="text" size="small" class="del-btn">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="platform-page">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      input: "",
      search: "",
      currentPage: 1,
      tableData: [
        {
          name: "某某云",
          user: "root",
          pass: "12345678",
          port: "22",
          address: "127.0.0.1",
          note: "默认端口"
        }
      ]
    };
  },
  methods: {
    onSubmit() {
      console.log("submit!");
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleClick(row) {
      // console.log(row.address);
      // console.log(row.pass);

      this.$cookies.set("ip",row.address);
      this.$cookies.set("user",row.user);
      this.$cookies.set("pass",row.pass);
      this.$cookies.set("port",row.port);

      this.$router.push("/ssh")
    }
  }
};
</script>

<style scoped>
.platform-search {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.search-ipt {
  width: 200px;
}
.platform-table {
  padding: 20px 0;
}
</style>
